package com.thb.pay.core.handler;

import com.google.common.collect.Maps;
import com.xiaoleilu.hutool.http.HttpUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.Method;
import java.util.Map;

public class SimpleUncaughtExceptionHandler implements UncaughtExceptionHandler {

    private final Logger logger = LoggerFactory.getLogger(SimpleUncaughtExceptionHandler.class);

    public static void main(String[] args) {
        try {
            Map<String, Object> paramMap = Maps.newHashMap();
//            paramMap.put("time", System.currentTimeMillis());
            String resultStr = HttpUtil.post("https://www.cnblogs.com/luchangyou/p/6375166.html", paramMap);
            System.out.println(resultStr);
        } catch (Exception e) {
            System.out.println("ex............");
            return;
        } finally {
            System.out.println("xxxxxxxxxxxxxxxxxx");
        }

    }

    @Override
    public void handleUncaughtException(Throwable ex, Method method, Object... params) {
        if (logger.isErrorEnabled()) {
            logger.error(String.format("Unexpected error occurred invoking async " +
                    "method '%s'. params '%s'", method, params), ex);
        }
    }

}